<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>模版列表</title>
    <link rel="stylesheet" href="/style/weui.css"/>
    <link rel="stylesheet" href="/style/swiper.min.css"/>
    <link rel="stylesheet" href="/style/example.css"/>
    <link rel="stylesheet" href="/style/sweetalert.css"/>
</head>
<body ontouchstart>
<div class="page">
    <div class="page__bd" style="height: 100%;">
        <div class="weui-tab">
            <div class="weui-tab__panel order-list" style="padding-bottom: 50px;">
                <!-- list -->
                <?php foreach ($list as $temp) { ?>
                    <div class="weui-panel weui-panel_access">
                        <div class="weui-panel__bd" onclick="javascript:location.href='/inventory/template-data?tempId=<?=$temp['id'] ?>&shopId=<?=$temp['shopId']?>'">
                            <div class="weui-media-box weui-media-box_appmsg">
                                <div class="weui-media-box__bd">
                                    <h5 class="weui-media-box__title">模版名称：<?=$temp['name'] ?></h5>
                                    <p style="float: left">门店：<?=$temp['ShopName'] ?></p>
                                    <p style="float: right">创建人：<?=$temp['creator'] ?></p>
                                </div>
                            </div>
                        </div>
                        <div class="weui-panel__ft">
                            <div class="weui-cell weui-cell_access weui-cell_link">
                                <div class="weui-cell__bd"></div>
                                <div class="weui-cell__ft button_sp_area">
                                    <a class="weui-btn weui-btn_mini weui-btn_primary"
                                       href="javascript:location.href='/inventory/template?tempId=<?=$temp['id']?>&tempName=<?=$temp['name']?>&shopId=<?=$temp['shopId']?>&shopName=<?=$temp['ShopName']?>&remark=<?=$temp['remark']?>'"
                                       style="background-color: #1aad19; line-height: 2.3" >修改</a>
                                    <a class="weui-btn weui-btn_mini weui-btn_default" name="del-temp-btn" data-id="<?=$temp['id'] ?>">删除</a>
                                </div>
                            </div>
                        </div>
                    </div>
                <?php } ?>
                <!-- list end-->
            </div>
            <div class="weui-form-preview__ft weui-footer_fixed-bottom" style="background-color: #fff; bottom: 0">
                <a class="weui-form-preview__btn" href="/">返回</a>
                <a class="weui-form-preview__btn weui-form-preview__btn_primary" href="/inventory/template">新增</a>
            </div>
        </div>
    </div>
</div>

<script src="/js/zepto.min.js"></script>
<script src="/js/sweetalert.min.js"></script>
<script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="https://res.wx.qq.com/open/libs/weuijs/1.0.0/weui.min.js"></script>
<script src="/js/swiper.min.js"></script>
<script>
    $(function () {
        $('a[name=del-temp-btn]').on('click', function () {
            var tempId = $(this).attr('data-id');
            swal({
                title: '提示',
                text: '是否确认删除？',
                confirmButtonText: "确认",
                cancelButtonText: "取消",
                showCancelButton: true,
                closeOnConfirm: false
            }, function (flg) {
                if (flg) {
                    $.post(
                        '/inventory/del-temp', {'tempId': tempId},
                        function (o) {
                            if (o.code == 200) {
                                swal('删除成功');
                                setTimeout(function () {
                                    location.reload();
                                }, 1500);
                            } else {
                                swal('操作失败');
                            }
                        },
                        'json'
                    );
                }
                swal.close();
            });
        });
    });
</script>
</body>
</html>
